<template>
    <div v-loading="loading" class="app-container">
      <x-table v-model="searchData" :config="tableConfig" :data="tableData" :page="page" :load="getMovieByPage" />
    </div>
  </template>
    
  <script>
  import { getMovieByPage, delMovieById } from '@/api/movie'
  import { getToken } from '@/utils/auth'
  import { importDic } from '@/utils'
  
  export default {
    data() {
      return {
        eSDic: 'findMovieExamineStatus',
        drawer: false,
        direction: 'rtl',
        loading: 0,
        tableData: [],
        page: {
          pageSizes: [10, 20],
          pageSize: 10,
          pageNum: 1,
          total: 0
        },
        searchData: {
          playStatus: 88
        },
        propId: '',
        dialogName: ''
      }
    },
  
    computed: {
      tableConfig() {
        const _this = this
        return {
          search: true,
          reset: true,
          stripe: false,
          border: true,
          highlightCurrentRow: true,
          rowClick: node => _this.$emit('cellClick', node),
          btn: [
            { text: '日历', click: () => { this.$router.push('/movieArrange/arrangeCalendar') }, icon: 'el-icon-date' }
          ],
          column: [
            { label: '电影名', name: 'movieName', search: true, xType: 'input' },
            { label: '电影类型', name: 'movieType', search: false, xType: 'input' },
            { label: '电影时长(min)', name: 'last', search: false, xType: 'input' },
          ],
          operate: [
            { text: '查看', show: true, click: data => this.operate2('detail', data) },
            { text: '排片', show: true, click: data => this.toArrange(data) }
          ]
        }
      }
    },
  
    mounted() {
      this.getMovieByPage()
    },
  
    methods: {
      getMovieByPage() {
        this.loading++
        getMovieByPage(this.searchData, this.page.pageNum, this.page.pageSize, getToken()).then(res => {
          console.log("getMovieByPage" + res)
          this.tableData = res.result.records
          this.page.total = res.result.total
        }).catch(e => console.error(e)).finally(() => this.loading--)
      },
      operate2(mode, data) {
        if (mode !== 'add') {
          this.propId = data.id
        }
        this.mode = mode
        this.$router.push({
          path: "/movieArrange/movieDetail",
          query: {
            mode: this.mode,
            id: this.propId
          }
        })
      },
      toArrange(data) {
        this.$router.push({
            path: "/movieArrange/newArrange",
            query: {
                movieName: data.movieName,
                id: data.id,
                last: data.last
            }
        })
      }
    },
  
  }
  </script>
    